package cn.hsa.xxx.bookOrder.controller;

import cn.hsa.hsaf.core.framework.web.WrapperResponse;
import cn.hsa.xxx.bookOrder.dto.OrderDTO;
import cn.hsa.xxx.bookOrder.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/web/bookOrder/Order")
@RestController
@Slf4j
public class OrderServiceController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/addOrder")
    public WrapperResponse<OrderDTO> addOrder(@RequestBody OrderDTO OrderDTO) {
        OrderDTO result = orderService.add(OrderDTO);
        return WrapperResponse.success(result);
    }

    @PostMapping("/deleteOrder")
    public WrapperResponse<String> deleteOrder(@RequestParam String id) {
        String result = orderService.delete(id);
        return WrapperResponse.success(result);
    }


    @GetMapping("/page")
    public WrapperResponse<List<OrderDTO>> getPageOrder(int pageNo, int pageSize) {
        List<OrderDTO> orderDTOList = orderService.getPage(pageNo, pageSize);
        return WrapperResponse.success(orderDTOList);
    }
}
